function $(a) {
    return document.getElementById(a)
}
function googleHint(a) {
    $("gsuggest") && $("gsuggest").parentNode.removeChild($("gsuggest"));
    var c = document.body.appendChild(document.createElement("script"));
    c.language = "javascript";
    c.id = "gsuggest";
    //c.charset = "utf-8";
    //c.src = "http://www.google.cn/complete/search?hl=zh-CN&client=suggest&js=true&q=" + encodeURIComponent(a);
	c.src = "http://suggestion.baidu.com/su?wd="+encodeURIComponent(a)+"&t="+(+new Date());
}
function setDisplay(a, c) {
    if ($(a)) $(a).style.display = c ? "block" : "none"
}
var searchs = {
    baidu: ["http://www.baidu.com/s", "wd", "\u767e\u5ea6", -1, "http://www.baidu.com/index.php"],
    google: ["http://www.google.com.hk/search", "q", "\u8c37\u6b4c", -29, "http://www.google.com.hk/webhp?client=aff-360daohang", "client:aff-360daohang;hl:zh-CN;ie:gb2312;newwindow:1"]
},currentInput;
 
function myhint(a) {
    a = a || event;
    var c = a.target || a.srcElement,
        b = $("suggest");
    currentInput = c;
    if (!c.value || !c.value.length || a.keyCode == 27 || a.keyCode == 13) b.style.display = "none";
    else if (a.keyCode == 38 || a.keyCode == 40) {
        if (b.style.display != "none") {
            if (a.keyCode == 38) if (b._i == -1) b._i = b.childNodes.length - 1;
            else b._i--;
            else b._i++;
            for (a = 0; a < b.childNodes.length; a++) b.childNodes[a].style.background = "#F8FCFF";
            if (b._i >= 0 && b._i < b.childNodes.length) with(b.childNodes[b._i]) {
                style.background = "#E6E6E6";
                c.value = b.childNodes[b._i].attributes._h.value
            } else {
                c.value =
                b._kw;
                b._i = -1
            }
        }
    } else {
        b._i = -1;
        b._kw = c.value;
        googleHint(c.value)
    }
}
window.baidu = {};
window.baidu.sug = function(a)
{
	if (a && a["s"] && a["q"] == currentInput.value) {
        var b = "";
        a = a["s"];
        if (a.length > 0) {
            for (var c = 0; c < a.length; c++) b += '<li style="cursor:hand"  onmousedown="$(\'' + currentInput.id + "').value='" + a[c] + "';setDisplay('suggest',0);javascript:searchSubmit(this);\" onmouseover=\"javascript:this.style.background='#E6E6E6'\" onmouseout=\"javascript:this.style.background='#F8FCFF';\" _h=\"" + a[c] + '">' + a[c] + "</li>";
            $("suggest").innerHTML = b;
            setDisplay("suggest", 1)
        } else {
            $("suggest").innerHTML = b;
            setDisplay("suggest", 0)
        }
    }
};
window.google = {};
window.google.ac = {};
window.google.ac.h = function (a) {
    if (a && a[1] && a[0] == currentInput.value) {
        var c = "";
        a = a[1];
        if (a.length > 0) {
            for (var b = 0; b < a.length; b++) c += '<li style="cursor:hand"  onmousedown="$(\'' + currentInput.id + "').value='" + a[b][0] + "';setDisplay('suggest',0);$('searchForm').submit();\" onmouseover=\"javascript:this.style.background='#E6E6E6'\" onmouseout=\"javascript:this.style.background='#F8FCFF';\" _h=\"" + a[b][0] + '">' + a[b][0] + "</li>";
            $("suggest").innerHTML = c;
            setDisplay("suggest", 1)
        } else {
            $("suggest").innerHTML = c;
            setDisplay("suggest", 0)
        }
    }
};
 
function setSearchHidden(a) {
    if (searchs[a][5] != null) {
        a = searchs[a][5].split(";");
        for (var c = 0, b = a.length; c < b; c++) {
            var d = a[c].split(":");
            if (d[0] == "tbs" && d[1] == "vid") d[1] = "vid:1";
            var e = document.createElement("INPUT");
            e.type = "hidden";
            e.name = d[0];
            e.id = d[0];
            e.value = d[1];
            $("hidpar").appendChild(e)
        }
    }
}
 
function changeSearch(a) {
	if(a=='baidu') $('searchLogo').style.marginTop='-3px';else $('searchLogo').style.marginTop='0';
	$('searchLogo').parentNode.href=searchs[a][4];
    $("searchLogo").src = "http://img.qihoo.com/images/2008/hao360/20100824/" + a + ".gif";
    $("hidpar").innerHTML = "";
    $("searchForm").action = searchs[a][0];
    $("kw1").name = searchs[a][1];
    setSearchHidden(a);
    return false
};